//
//  UIBarButtonItem+CreateBarButtonItem.m
//  百思不得姐
//
//  Created by 胥鸿儒 on 16/6/10.
//  Copyright © 2016年 xuhongru. All rights reserved.
//

#import "UIBarButtonItem+CreateBarButtonItem.h"

@implementation UIBarButtonItem (CreateBarButtonItem)

+ (instancetype)itemWithImage:(NSString *)image highlightedImage:(NSString *)highlightedImage target:(id)target action:(SEL)action{

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage originalImageNamed:image] forState:UIControlStateNormal];
    [button setImage:[UIImage originalImageNamed:highlightedImage] forState:UIControlStateHighlighted];
    
    [button sizeToFit];
    
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc]initWithCustomView:button];
}

@end
